<%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link href="${pageContext.request.contextPath}/static/assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/style.css"/>
    <link href="${pageContext.request.contextPath}/static/assets/css/codemirror.css" rel="stylesheet">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/assets/css/ace.min.css"/>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/font/css/font-awesome.min.css"/>
    <!--[if lte IE 8]>
		  <%--<link rel="stylesheet" href="${pageContext.request.contextPath}/static/assets/css/ace-ie.min.css" />--%>
		<![endif]-->
    <script src="${pageContext.request.contextPath}/static/js/jquery-1.9.1.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/assets/js/bootstrap.min.js"></script>
    <script type="text/javascript"
            src="${pageContext.request.contextPath}/static/Widget/Validform/5.3.2/Validform.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/assets/js/typeahead-bs2.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/assets/js/jquery.dataTables.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/assets/js/jquery.dataTables.bootstrap.js"></script>
    <script src="${pageContext.request.contextPath}/static/assets/layer/layer.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/js/lrtk.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/assets/layer/layer.js" type="text/javascript"></script>
    <script src="${pageContext.request.contextPath}/static/assets/laydate/laydate.js" type="text/javascript"></script>
    <title>管理员</title>
</head>

<body>
<div class="page-content clearfix">
    <div class="administrator">
        <div class="d_Confirm_Order_style">
            <div class="search_style">
                <ul class="search_content clearfix">
                    <form action="${pageContext.request.contextPath}/ad/getsearch" method="post">
                        <li><label class="l_f">管理员名称</label>
                            <input name="name" type="text" class="text_add" placeholder="搜索"
                                   style=" width:250px"/></li>
                        <li style="width:90px;">
                            <button type="button" class="btn_search"><i class="fa fa-search"></i>查询</button>
                        </li>
                    </form>
                </ul>
               <%-- <form action="${pageContext.request.contextPath}/ad/getsearch" method="post" >
                    管理员名称:<input id="text" name="name" type="text" placeholder="搜索">
                    <button type="submit" style="color: #00a2d4;" class="btn_search"><i class="fa fa-search"></i>查询</button>
                </form>--%>
                <%--<ul class="search_content clearfix">
                    <li><label class="l_f">管理员名称</label>
                        <input name="" type="text" class="text_add" placeholder="" style=" width:400px"/></li>

                    &lt;%&ndash;<li><label class="l_f">添加时间</label><input class="inline laydate-icon" id="start"
                                                              style=" margin-left:10px;"></li>&ndash;%&gt;
                    <li style="width:90px;">
                        <button type="button" class="btn_search"><i class="fa fa-search"></i>查询</button>
                    </li>
                </ul>--%>
            </div>
            <!--操作-->
            <div class="border clearfix">
       <span class="l_f">
        <a href="javascript:ovid()" id="administrator_add" onclick="admin_add()" class="btn btn-warning"><i class="fa fa-plus"></i> 添加管理员</a>
       <%-- <a href="javascript:ovid()" class="btn btn-danger"><i class="fa fa-trash"></i> 批量删除</a>--%>
       </span>
               <%-- <span class="r_f">共：<b>11</b>人</span>--%>
            </div>
            <!--管理员列表-->
            <div class="clearfix administrator_style" id="administrator">
                <div class="left_style">
                    <div id="scrollsidebar" class="left_Treeview">
                        <div class="show_btn" id="rightArrow"><span></span></div>
                        <div class="widget-box side_content">
                            <div class="side_title"><a title="隐藏" class="close_btn"><span></span></a></div>
                            <div class="side_list">
                                <div class="widget-header header-color-green2"><h4 class="lighter smaller">管理员分类列表</h4>
                                </div>
                               <%-- <c:forEach items="${allcount}" var="count" varStatus="i">--%>
                                <div class="widget-body">
                                    <ul class="b_P_Sort_list">
                                        <li><i class="fa fa-users green"></i> <a href="#">全部管理员</a></li>
                                        <li><i class="fa fa-users orange"></i> <a href="#">超级管理员</a></li>
                                        <li><i class="fa fa-users orange"></i> <a href="#">普通管理员</a></li>
                                       <%-- <li><i class="fa fa-users orange"></i> <a href="#">产品编辑管理员（4）</a></li>
                                        <li><i class="fa fa-users orange"></i> <a href="#">管理员（1）</a></li>--%>
                                    </ul>

                                </div>
                                <%--</c:forEach>--%>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="table_menu_list" id="testIframe">
                    <table class="table table-striped table-bordered table-hover" id="sample_table">
                        <thead>
                        <tr>
                            <th width="25px"><label><input type="checkbox" class="ace"><span class="lbl"></span></label>
                            </th>
                            <th width="80px">编号</th>
                            <th width="200px">管理员名称</th>
                            <th width="100px">年龄</th>
                            <th width="100px">性别</th>
                            <th width="100px">手机</th>
                            <th width="100px">角色</th>
                            <%--<th width="180px">加入时间</th>--%>
                            <th width="70px">状态</th>
                            <th width="200px">操作</th>
                        </tr>
                        </thead>
                        <tbody>
                        <c:forEach items="${adminList}" var="admin" varStatus="i">
                            <tr>
                                <td><label><input type="checkbox" class="ace"><span class="lbl"></span></label></td>
                                <td>${admin.adminid}</td>
                                <td>${admin.name}</td>
                                <td>${admin.age}</td>
                                <td>${admin.sex}</td>
                                <td>${admin.phone}</td>
                                <td>${admin.rolename}</td>
                                <%--<td>超级管理员</td>--%>
                                <%--<td>${admin.cratedate}</td>--%>
                                <td class="td-status"><span class="label label-success radius">已启用</span></td>
                                <td class="td-manage">
                                    <c:if test="${admin.rolemid!=1}">
                                        <a onClick="member_stop(this,'10001')" href="javascript:;" title="停用"
                                           class="btn btn-xs btn-success"><i class="fa fa-check  bigger-120"></i></a>
                                        <a title="编辑" onclick="admin_edit('${admin.adminid}')" href="javascript:;"
                                           class="btn btn-xs btn-info"><i class="fa fa-edit bigger-120"></i></a>
                                        <a title="删除" <%--href="javascript:;" onclick="member_del(this,'1')"--%>
                                           href="${pageContext.request.contextPath}/ad/deleteByID?adminid=${admin.adminid}"
                                           class="btn btn-xs btn-warning"><i class="fa fa-trash  bigger-120"></i></a>
                                    </c:if>
                                    <c:if test="${admin.rolemid==1}">
                                        <a>权限最高,不可更改<i
                                        ></i></a>
                                    </c:if>

                                </td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
    <!--添加管理员adminid,name,password,sex,age,status,createdate,phone-->
    <div class="add_administrator_style1" id="add_menber" style="display:none">
        <form action="" method="post" id="form-admin-add">
            <div class="form-group">
                <label class="form-label"><span class="c-red" style="color:Red;">*</span>管理员：</label>
                <div class="formControls">
                    <input type="text" class="input-text"  placeholder="" id="user-name" name="name11"
                           datatype="*2-16" nullmsg="用户名不能为空">
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>
            <div class="form-group">
                <label class="form-label"><span class="c-red" style="color:Red;">*</span>密码：</label>
                <div class="formControls">
                    <input type="password"  placeholder="密码" name="userpassword" autocomplete="off" value=""
                           class="input-text" datatype="*6-20" nullmsg="密码不能为空">
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>
            <%--<div class="form-group">
                <label class="form-label "><span class="c-red" style="color:Red;">*</span>确认密码：</label>
                <div class="formControls ">
                    <input type="password" name="userpassword" placeholder="确认新密码" autocomplete="off" class="input-text Validform_error"
                           errormsg="您两次输入的新密码不一致！" datatype="*" nullmsg="请再输入一次新密码！" recheck="userpassword"
                           id="newpassword">
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>--%>
            <div class="form-group">
                <label class="form-label "><span class="c-red" style="color:Red;">*</span>性别：</label>
                <div class="formControls  skin-minimal">
                    <label><input name="form-field-radio" type="radio" value="男" class="ace" checked="checked"><span class="lbl">男</span></label>&nbsp;&nbsp;
                    <label><input name="form-field-radio" type="radio" value="女" class="ace"><span class="lbl">女</span></label>
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>
            <div class="form-group">
                <label class="form-label "><span class="c-red" style="color:Red;">*</span>手机：</label>
                <div class="formControls ">
                    <input type="text" name="phone" class="input-text" value="" placeholder="" id="user-tel"
                           datatype="m" nullmsg="手机不能为空">
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>
            <div class="form-group">
                <label class="form-label"><span class="c-red" style="color:Red;">*</span>年龄：</label>
                <div class="formControls ">
                    <input type="text" name="age" class="input-text" nullmsg="年龄不能为空">
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>
            <div class="form-group">
                <label class="form-label">角色：</label>
                <div class="formControls "> <span class="select-box" style="width:150px;" name="rolename">
				<select id="selected" class="select1" name="admin-role" size="1" >
					<%--<option value="超级管理员" name="select">超级管理员</option>--%>
					<option value="普通管理员" name="select">普通管理员</option>
					<%--<option value="普通管理员">商家</option>
					<option value="普通管理员">其它</option>--%>
				</select>
				</span></div>
            </div>
            <div class="form-group">
                <label class="form-label">备注：</label>
                <div class="formControls">
                    <textarea name="" cols="" rows="" class="textarea" placeholder="说点什么...100个字符以内" dragonfly="true"
                              onkeyup="checkLength(this);"></textarea>
                    <span class="wordage">剩余字数：<span id="sy" style="color:Red;">100</span>字</span>
                </div>
                <div class="col-4"></div>
            </div>
<%--            <div>
                <input class="btn btn-primary radius" type="submit" id="Add_Administrator"
                       value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>--%>
        </form>
    </div>
    <!--编辑管理员-->
    <div class="add_administrator_style" id="edit_admin" style="display:none">
        <form action="" method="post" id="form-admin-add1">
            <div class="form-group">
                <label class="form-label"><span class="c-red" style="color:Red;">*</span>登录名：</label>
                <div class="formControls">
                    <input value="${admin1.name}" type="text" class="input-text" placeholder="" id="user-name1" name="name1"
                           datatype="*2-16" nullmsg="用户名不能为空" readonly="readonly">
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>
<%--            <div class="form-group">
                <label class="form-label"><span class="c-red" >*</span>初始密码：</label>
                <div class="formControls">
                    <input value="${admin1.password}" type="password" placeholder="密码" name="password" autocomplete="off"
                           class="input-text" datatype="*6-20" nullmsg="密码不能为空">
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>
            <div class="form-group">
                <label class="form-label "><span class="c-red">*</span>确认密码：</label>
                <div class="formControls ">
                    <input type="password" value="${admin1.password}" placeholder="确认新密码" autocomplete="off" class="input-text Validform_error"
                           errormsg="您两次输入的新密码不一致！" datatype="*" nullmsg="请再输入一次新密码！" recheck="userpassword"
                           id="newpassword1" name="password">
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>--%>
            <div class="form-group">
                <label class="form-label"><span class="c-red" style="color:Red;">*</span>初始密码：</label>
                <div class="formControls">
                    <input type="password" value="${admin1.password}" placeholder="密码" name="password" autocomplete="off"
                           class="input-text" datatype="*6-20" nullmsg="密码不能为空" readonly="readonly">
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>
            <%--<div class="form-group">
                <label class="form-label "><span class="c-red" style="color:Red;">*</span>确认密码：</label>
                <div class="formControls ">
                    <input type="password" name="password" placeholder="确认新密码" autocomplete="off" class="input-text Validform_error"
                           errormsg="您两次输入的新密码不一致！" datatype="*" nullmsg="请再输入一次新密码！" recheck="userpassword"
                           id="newpassword1" readonly="readonly">
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>--%>
           <div class="form-group">
                <label class="form-label "><span class="c-red" style="color:Red;" >*</span>性别：</label>
                <div class="formControls  skin-minimal">
                    <c:if test="${admin1.sex=='男'}">
                        <label><input name="form-field-radio" value="男" type="radio" checked="checked" class="ace"><span class="lbl">男</span></label>&nbsp;&nbsp;
                        <label><input name="form-field-radio" value="女" type="radio" class="ace"><span class="lbl">女</span></label>
                    </c:if>
                    <c:if test="${admin1.sex=='女'}">
                        <label><input name="form-field-radio" value="男" type="radio" class="ace"><span class="lbl">男</span></label>&nbsp;&nbsp;
                        <label><input name="form-field-radio" value="女" type="radio" checked="checked" class="ace"><span class="lbl">女</span></label>
                    </c:if>
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>
            <div class="form-group">
                <label class="form-label "><span class="c-red" style="color:Red;">*</span>手机：</label>
                <div class="formControls ">
                    <input id="mobilephone" value="${admin1.phone}"type="text"  class="input-text"
                           datatype="m" nullmsg="手机不能为空">
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>
            <div class="form-group">
                <label class="form-label"><span class="c-red" style="color:Red;">*</span>年龄：</label>
                <div class="formControls ">
                    <input  id="oldage" value="${admin1.age}" type="text" nullmsg="年龄不能为空">
                </div>
                <div class="col-4"><span class="Validform_checktip"></span></div>
            </div>
            <div class="form-group">
                <label class="form-label">角色：</label>
                <div class="formControls "> <span class="select-box" style="width:150px;">
				<select id="select" class="select" name="admin-role" size="1">
					<%--<option value="超级管理员">超级管理员</option>--%>
					<option value="普通管理员">普通管理员</option>
					<%--<option value="普通管理员">商家</option>
					<option value="普通管理员">其它</option>--%>
				</select>
				</span></div>
            </div>
            <%--<div class="form-group">
                <label class="form-label">备注：</label>
                <div class="formControls">
                    <textarea name="" cols="" rows="" class="textarea" placeholder="说点什么...100个字符以内" dragonfly="true"
                              onkeyup="checkLength(this);"></textarea>
                    <span class="wordage">剩余字数：<span id="sy1" style="color:Red;">100</span>字</span>
                </div>
                <div class="col-4"></div>
            </div> --%>
            <%--<div>
                <input class="btn btn-primary radius" type="submit" id="Add_Administrator"
                       value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
            </div>--%>
        </form>
    </div>
</div>
</body>
<script>
/*    /!* name,password,sex,age,status,createdate,phone *!/
    function refreshImg() {
        var name=document.getElementsByName(name).value;
        var password=document.getElementsByName(password).value;
        /!*var reppassword=document.getElementsByName(reppassword).value;*!/
        var sex=document.getElementsByName(sex).value;
        /!*var sex=document.getElementsByName(sex).value;*!/
        var age=document.getElementsByName(age).value;
        var phone=document.getElementsByName(phone).value;
        if(name!=null){
            var url = “${staticPath}${pageContext.request.contextPath}/ad/addadmin";
            $.ajax({
                url: url,
                method: 'post',
                data: {"name":name,"password":password,"sex":sex,"age":age,"phone":phone,"rolemid":rolemid},
                dataType: 'JSON',
                success: function(data) {
                    if (data.success) {
                        layer.msg("添加成功", {
                            offset: '60px',
                            icon: 6,
                            anim: 6,
                            time: 1000
                        });
                        window.location.href='${path}/pages/administrator';
                    } else {
                        refreshImg();
                        console.log("错误信息是: " + data.msg);
                        layer.msg(data.msg, {
                            offset: '60px',
                            icon: 5,
                            anim: 6,
                            time: 3000
                        });
                    }
                }
            });
        }else{
            alert("请重新输入密码，密码错误?");
        }

    }*/
</script>

<script type="text/javascript">
    jQuery(function ($) {
        var oTable1 = $('#sample_table').dataTable({
            "aaSorting": [[1, "desc"]],//默认第几个排序
            "bStateSave": true,//状态保存
            "aoColumnDefs": [
                //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
                {"orderable": false, "aTargets": [0, 2, 3, 4, 5, 7, 8,]}// 制定列不参与排序
            ]
        });


        $('table th input:checkbox').on('click', function () {
            var that = this;
            $(this).closest('table').find('tr > td:first-child input:checkbox')
                .each(function () {
                    this.checked = that.checked;
                    $(this).closest('tr').toggleClass('selected');
                });

        });


        $('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});

        function tooltip_placement(context, source) {
            var $source = $(source);
            var $parent = $source.closest('table')
            var off1 = $parent.offset();
            var w1 = $parent.width();

            var off2 = $source.offset();
            var w2 = $source.width();

            if (parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2)) return 'right';
            return 'left';
        }
    });

</script>
<script type="text/javascript">
    $(function () {
        $("#administrator").fix({
            float: 'left',
            //minStatue : true,
            skin: 'green',
            durationTime: false,
            spacingw: 50,//设置隐藏时的距离
            spacingh: 270,//设置显示时间距
        });
    });

    //字数限制
    function checkLength(which) {
        var maxChars = 100; //
        if (which.value.length > maxChars) {
            layer.open({
                icon: 2,
                title: '提示框',
                content: '您输入的字数超过限制!',
            });
            // 超过限制的字数了就将 文本框中的内容按规定的字数 截取
            which.value = which.value.substring(0, maxChars);
            return false;
        } else {
            var curr = maxChars - which.value.length; //250 减去 当前输入的
            document.getElementById("sy").innerHTML = curr.toString();
            return true;
        }
    };
    //初始化宽度、高度
    $(".widget-box").height($(window).height() - 215);
    $(".table_menu_list").width($(window).width() - 260);
    $(".table_menu_list").height($(window).height() - 215);
    //当文档窗口发生改变时 触发
    $(window).resize(function () {
        $(".widget-box").height($(window).height() - 215);
        $(".table_menu_list").width($(window).width() - 260);
        $(".table_menu_list").height($(window).height() - 215);
    })

    laydate({
        elem: '#start',
        event: 'focus'
    });

    /*用户-停用*/
    function member_stop(obj, id) {
        layer.confirm('确认要停用吗？', function (index) {
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs " onClick="member_start(this,id)" href="javascript:;" title="启用"><i class="fa fa-close bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已停用</span>');
            $(obj).remove();
            layer.msg('已停用!', {icon: 5, time: 1000});
        });
    }

    /*用户-启用*/
    function member_start(obj, id) {
        layer.confirm('确认要启用吗？', function (index) {
            $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" class="btn btn-xs btn-success" onClick="member_stop(this,id)" href="javascript:;" title="停用"><i class="fa fa-check  bigger-120"></i></a>');
            $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
            $(obj).remove();
            layer.msg('已启用!', {icon: 6, time: 1000});
        });
    }

    /*产品-编辑*/
    /*function member_edit(title, url, id, w, h) {
        layer_show(title, url, id, w, h);
    }*/
   /* function member_edit(id) {
        var name=document.getElementsByName(name).value;
        /!*var password=document.getElementsByName(password).value;
        var reppassword=document.getElementsByName(reppassword).value;*!/
        /!*var sex=document.getElementsByName(sex).value;*!/
        var age=document.getElementsByName(age).value;
        var phone=document.getElementsByName(phone).value;
        var rolename=document.getElementsByName(rolename).value;

        layer.open({
            type: 1,
            title: '修改用户信息',
            maxmin: true,
            shadeClose: false, //点击遮罩关闭层
            area: ['800px', ''],
            content: $('#add_administrator_style1'),
            btn: ['提交', '取消'],
            yes: function (index, layero) {
                var num = 0;
                var str = "";
                $(".add_menber input[type$='text']").each(function (n) {
                    if ($(this).val() == "") {

                        layer.alert(str += "" + $(this).attr("name") + "不能为空！\r\n", {
                            title: '提示框',
                            icon: 0,
                        });
                        num++;
                        return false;
                    }
                });
                if (num > 0) {
                    return false;
                } else {
                    layer.alert('编辑成功！', {
                        title: '提示框',
                        icon: 1,
                    });
                    layer.close(index);
                }
            }
        });
    }*/
    /*管理员-编辑*/
    function admin_edit(adminid) {
        //alert(adminid);
        var pathName=document.location.pathname;
        console.log("pathName="+pathName);
        var index=pathName.substr(1).indexOf("/");
        var result=pathName.substr(0,index+1);
        console.log(result);
        //alert(result);
        $.ajax({
            url:result+"/ad/edit",
            type:"get",
            data:{adminid:adminid},
            dataType:"json",
            success:function (data) {
                if (data.success) {
                    layer.open({
                        type: 1,
                        title: '修改管理员信息',
                        maxmin: true,
                        shadeClose: false, //点击遮罩关闭层
                        area: ['800px', ''],
                        content: $('#edit_admin'),
                        btn: ['提交', '取消'],
                        yes: function (index, layero) {
                            var num = 0;
                            var str = "";
                            $("#edit_admin input[type$='text']").each(function (n) {
                                if ($(this).val() == "") {

                                    layer.alert(str += "" + $(this).attr("name") + "不能为空！\r\n", {
                                        title: '提示框',
                                        icon: 0,
                                    });
                                    num++;
                                    return false;
                                }
                            });
                            /*"name":name,"password":password,"sex":sex,"age":age,"phone":phone,"rolemid":rolemid*/
                            var name=$('input[name="name1"]').val();
                            console.log("name="+name);
                            var password=$('input[name="password"]').val();
                            console.log("password="+password);
                            var sex=$('input[name="form-field-radio"]:checked').val();
                            console.log("sex="+sex);
                            /*var options=$(“.select”); //获取选中的项*/
                            var rolename=$("#select").val();
                            console.log("rolename="+rolename);
                            var age=$('input[id="oldage"]').val();
                            console.log("age="+age);
                            var phone=$('input[id="mobilephone1"]').val();
                            console.log("phone="+phone);
                            if (num > 0) {
                                return false;
                            } else {
                                $.ajax({
                                    url:result+"/ad/updateAdmin",
                                    type:"get",
                                    data:{adminid:adminid,
                                        name:name,
                                        password:password,
                                        sex:sex,
                                        age:age,
                                        phone:phone,
                                        rolename:rolename
                                    },
                                    dataType:"json",
                                    success:function (data) {
                                        if (data.success) {

                                            //alert(num);
                                            layer.alert('修改成功！', {
                                                title: '提示框',
                                                icon: 1,
                                            });
                                            layer.close(index);
                                        }else {
                                            alert("修改失败");
                                        }
                                    }
                                })


                            }
                        }
                    });
                }else{
                    alert("修改失败");
                }
            }
        })
    }
    /*管理员-添加*/
    function admin_add() {
        var pathName=document.location.pathname;
        console.log("pathName="+pathName);
        var index=pathName.substr(1).indexOf("/");
        var result=pathName.substr(0,index+1);
        console.log(result);
        //alert(result);

        layer.open({
            type: 1,
            title: '添加管理员',
            maxmin: true,
            shadeClose: false, //点击遮罩关闭层
            area: ['700px', ''],
            content: $('#add_menber'),
            btn: ['提交', '取消'],
            yes: function (index, layero) {
                var num = 0;
                var str = "";
                $("#add_menber input[type$='text']").each(function (n) {

                    //alert($(this).val());
                    //alert(n);
                    if ($(this).val() == "") {

                        layer.alert(str += "" + $(this).attr("name") + "不能为空！\r\n", {
                            title: '提示框',
                            icon: 0,
                        });
                        num++;
                        return false;
                    }
                });
                /*"name":name,"password":password,"sex":sex,"age":age,"phone":phone,"rolemid":rolemid*/
                var name=$('input[name="name11"]').val();
                console.log("name="+name);

                var password=$('input[name="userpassword"]').val();
                console.log("password="+password);

                var sex=$('input[name="form-field-radio"]:checked').val();
                console.log("sex="+sex);

                var age=$('input[name="age"]').val();
                console.log("age="+age);

                var phone=$('input[name="phone"]').val();
                console.log("phone="+phone);

                /*var options=$(“.select”); //获取选中的项*/
                var rolename=$("#selected").val();
                /*var rolename=$('input[name="rolename"]').val();*/
                console.log("rolename="+rolename);

                if (num > 0) {
                    return false;
                } else {
                    $.ajax({
                        url:result+"/ad/addadmin",
                        type:"get",
                        data:{
                            name:name,
                            password:password,
                            sex:sex,
                            age:age,
                            phone:phone,
                            rolename:rolename
                        },
                        dataType:"json",
                        success:function (data) {
                            if (data.success) {

                                //alert(num);
                                layer.alert('添加成功！', {
                                    title: '提示框',
                                    icon: 1,
                                });

                                layer.close(index);


                            }else {
                                alert("添加失败");
                            }
                        }
                    })


                }
            }
        });

    }

    /*产品-删除*/
    function member_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            $(obj).parents("tr").remove();
            layer.msg('已删除!', {icon: 1, time: 1000});
        });
    }

    /*添加管理员*/
/*    $('#administrator_add').on('click', function () {
        layer.open({
            type: 1,
            title: '添加管理员',
            area: ['700px', ''],
            shadeClose: false,
            content: $('#add_administrator_style'),

        });
    })*/
    //表单验证提交
    $("#form-admin-add").Validform({

        tiptype: 2,

        callback: function (data) {
            //form[0].submit();
            if (data.status == 1) {
                layer.msg(data.info, {icon: data.status, time: 1000}, function () {
                    location.reload();//刷新页面 
                });
            } else {
                layer.msg(data.info, {icon: data.status, time: 3000});
            }
            var index = parent.$("#iframe").attr("src");
            parent.layer.close(index);
            //
        }


    });
</script>

